package com.cg.managesystem.controller;

import com.cg.managesystem.entity.User;
import com.cg.managesystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created on 2019/8/14 by Tinchi
 **/
@RestController
public class HelloController {
    @Autowired
    private UserService userService;

    /**
     * 测试方法，用来检验路径是否正确
     *
     * @return "hello"
     */
    @PostMapping(value = "/index")
    public ModelAndView hello1() {
        return new ModelAndView("test");
    }

    @GetMapping(value = "/admin")
    public ModelAndView index() {
        List<User> users = userService.selectAll();
        ModelAndView mv = new ModelAndView("admin/index");
        mv.addObject("users", users);
        return mv;
    }

    @GetMapping(value = "/post")
    public ModelAndView index2() {
        return new ModelAndView("post/index");
    }

    @GetMapping(value = "/room")
    public ModelAndView index3() {
        return new ModelAndView("room/index");
    }

    @GetMapping(value = "/picture")
    public ModelAndView index4() {
        return new ModelAndView("picture/index");
    }


}


